<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>授权登录</title>
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link href="../css/mui.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="../css/commons.css">
    <style>

    </style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" href="index.html"></a>
    <h1 class="mui-title">授权登录</h1>
</header>
<!--
    作者：837081299@qq.com
    时间：2017-02-28
    描述：头部结束
-->
<div id="refreshContainer" class="mui-content mui-scroll-wrapper">
    <div class="mui-content">
        <input id="id_securityCode_input">
        <button id="scanQRCode">扫码</button>
    </div>
</div>
<script src="../js/mui.min.js"></script>
<script src="../js/jquery-1.10.1.min.js"></script>
<script src="../js/sha1.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>  document.write("<s"+"cript type='text/javascript' src='../js/common.js?"+Math.random()+"'></scr"+"ipt>"); </script>

<script>
    //扫一扫
    var ticket;
    var timer;
    var wxSha1;
    var shareMoney = GetQueryString('money')
    $(function () {
        $.ajax({
            url:'/shareC/getAccessToken.json',
            dataType:'json',
            type:'post',
            success:function (data) {
                //console.log(data);
                ticket = data.datas;
                //ticket = 'kgt8ON7yVITDhtdwci0qeQa8Ki1WA1wFqPG86V5WrfLFookrccU4Z9LoNvQ9B8CE5k7gxYJREYH3kC_89JOIJQ';
                timer = Date.parse(new Date());
                timer = timer / 1000;
                var WXsignature = 'jsapi_ticket=' + ticket + '&noncestr=Wm3WZYTPz0wzccnW&timestamp=' + timer + '&url=' + location.href.split('#')[0]
                wxSha1 = hex_sha1(WXsignature);
                //console.log(WXsignature);
                //console.log(wxSha1);
                wx.config({
                    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                    appId: 'wxfe59dbeae5082ce6', // 必填，公众号的唯一标识
                    timestamp: timer, // 必填，生成签名的时间戳
                    nonceStr: 'Wm3WZYTPz0wzccnW', // 必填，生成签名的随机串
                    signature: wxSha1,// 必填，签名，见附录1
                    jsApiList: ['scanQRCode'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
                });

                wx.ready(function(){
                    // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，
                    wx.checkJsApi({
                        jsApiList: ['onMenuShareAppMessage','onMenuShareTimeline'], // 需要检测的JS接口列表，所有JS接口列表见附录2,
                        success: function(res) {
                            // 以键值对的形式返回，可用的api值true，不可用为false
                            // 如：{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
                        },
                        fail:function () {
                            mui.alert('您的微信版本过低，暂不支持分享，请升级微信')
                        }
                    });


                });
            }



            //}
        })
    })
    //扫一扫
    $("#scanQRCode").click(function() {
        wx.scanQRCode({
            // 默认为0，扫描结果由微信处理，1则直接返回扫描结果
            needResult : 1,
            desc : 'scanQRCode desc',
            success : function(res) {
                //扫码后获取结果参数赋值给Input
                var url = res.resultStr;
                //var result = url.GetQueryString('cardId');
                alert(url);
                varCts = "cardId";
                if(url.indexOf('cardId') > -1 ){
                    alert('Cts中包含Text字符串');
                }else{
                    alert('不包含')
                }
                //商品条形码，取","后面的
                //if(url.indexOf(",")>=0){
                    //var tempArray = url.split(',');
                    //var tempNum = tempArray[1];
                    //$("#id_securityCode_input").val(tempNum);
                //}else{
                    //$("#id_securityCode_input").val(url);
                    //var result = url.GetQueryString('userId');
                    //alert(url);
                    //window.location.href=url
                //}
            }
        });
    });

</script>
</body>
</html>